<?php

declare(strict_types=1);

namespace app\api\controller\v1;
use app\common\Frontend;
use app\common\model\PublicStatus;
use app\common\model\RechargeCoin;

class Coin extends Frontend
{

    protected array $noNeedLogin = ['coinList'];

    protected $model;
    protected $price;
    public function initialize(): void
    {
        parent::initialize();
        $this->model = new RechargeCoin();
    }


    //类型数据源
    public function coinList() : void {
        $res =$this->model->where(['status'=>PublicStatus::PUBLIC_STATUS_ONE])->order('weight asc')->limit(4)->select()->each(function($item,$key){
            $item['price'] = intval($item['price']);
            return $item;
        })->toArray();
        $this->success('', [
            'list'   => $res,
            'remark' => '',
        ]);
    }
}